package com.clf.springCloudAccount.service.impl;

import com.clf.account.Role;
import com.clf.springCloudAccount.dao.RoleDao;
import com.clf.springCloudAccount.service.RoleService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Optional;

/**
 * @Description RoleService
 * @Author chenglongfei
 * @Date 2022/7/7 16:21
 */
@Service
public class RoleServiceImpl implements RoleService {

	@Autowired
	private RoleDao roleDao;

	@Override
	public List<Role> getRoles() {
		return Optional.ofNullable(roleDao.getRoles()).orElse(Collections.emptyList());
	}

	@Override
	public List<Role> getRolesByUserId(int userId) {
		return Optional
				.ofNullable(roleDao.getRolesByUserId(userId))
				.orElse(Collections.emptyList());
	}
}
